﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using QuanLiNhaSachDTO;

namespace QuanLiNhaSachDAO
{
    public class QuiDinhDAO
    {
        public static string LayGiaTri(string s)
        {
            string sql = "SELECT GiaTri FROM THAMSO WHERE Ten='" + s + "'";
            SqlDataAdapter da = new SqlDataAdapter(sql, sqlDB.MyConnection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt.Rows[0][0].ToString();
        }

        public static void Luu(string Ten, string GiaTri)
        {
            string sql = "UPDATE THAMSO SET GiaTri = @GiaTri WHERE Ten = @Ten";
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.Connection = sqlDB.MyConnection;
            cmd.Parameters.AddWithValue("@GiaTri", GiaTri);
            cmd.Parameters.AddWithValue("@Ten", Ten);
            cmd.ExecuteNonQuery();
        }
    }
}
